package 携程;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * @author zhangmin
 * @create 2022-04-14 18:41
 */
public class Main {

    public static void main(String[] args) {
        //接输入
        Scanner cin=new Scanner(System.in);
        int n=cin.nextInt();
        int[] nums=new int[n];
        for (int i = 0; i < n; i++) {
            nums[i]=cin.nextInt();
        }
        cin.nextLine();
        char[] colors=cin.nextLine().toCharArray();
        //开始统计
        Map<Integer,int[]> map=new HashMap<>();
        for (int i = 0; i < n; i++) {
            char c=colors[i];
            int num=nums[i];
            int[] mapc = map.getOrDefault(num, new int[]{0, 0});
            //map里面的数值，第一个存红色num的个数，第二个存蓝色num的个数
            if (c=='R'){
                mapc[0]++;
            }else if (c=='B'){
               mapc[1]++;
            }
            map.put(num,mapc);
        }
        int res=0;
        for (Map.Entry<Integer,int[]> entry:map.entrySet()) {
            res+=entry.getValue()[0]* entry.getValue()[1];
        }
        System.out.println(res);
    }
}
